package nextoffer;

/**
 * @author ：szq
 * @date ：Created in 2022/3/16 17:47
 * @description：调整数组顺序使奇数位于偶数前面
 * @modified By：
 * @version: $
 */
public class evennumbers {

    public int[] exchange(int[] nums) {


        int l = 0 ,r = nums.length-1;

        // 1 4 2 7 3 5
            while(l<r&&nums[r]%2==0)r--;
             int t = nums[r];nums[r] = nums[l] ;nums[l] = nums[r];



            while(l<r&&nums[l]%2!=0)l++;
             t = nums[r];nums[r] = nums[l] ;nums[l] = nums[r];
            return  nums;

        }


    }

